package com.csxy.systemmanager.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csxy.systemmanager.dao.SupplierDao;
import com.csxy.systemmanager.entity.Supplier;
import com.csxy.systemmanager.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (Good)表服务实现类
 *
 * @author makejava
 * @since 2024-06-15 15:15:30
 */
@Service("suppliersService")
public class SupplierServiceImpl extends ServiceImpl<SupplierDao, Supplier> implements SupplierService {

    @Autowired
    SupplierDao supplierDao;
    @Override
    public Page<Supplier> listByPage(Integer current, Integer size, String query) {
        Page<Supplier> page = new Page<>(current, size);
        if (query != null && !query.isEmpty()) {
            LambdaQueryChainWrapper<Supplier> like = new LambdaQueryChainWrapper<>(this.baseMapper).like(Supplier::getSupplierName, query);
            return like.page(page);
        }
        return this.baseMapper.selectPage(page, null);
    }

    @Override
    public List<Supplier> findByConditions(String supplierName) {
        return supplierDao.findByConditions(supplierName);
    }

}

